﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WCFMINERP.DAL;
using WCFMINERP.COM;

namespace WCFMINERP.BLL.PrintShopBill
{
    public class WorkFlowListBLL
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curTechId"></param>
        /// <param name="operUid"></param>
        /// <param name="oi"></param>
        /// <param name="dataBase"></param>
        /// <param name="strNextTechName"></param>
        /// <param name="IsNeedMoveData">是否需要移动数据</param>
        /// <returns></returns>
        private bool OverCurTechBase(int curTechId, int operUid, orderInfo oi, newSampleYPDBEntities dataBase, out string strNextTechName, out bool IsNeedMoveData)
        {
            DateTime dateTimeNow = CommonMethodDAL.GetServerTime();//取得当前的系统时间
            IsNeedMoveData = false;
            strNextTechName = "";//下一节点的名称
            double PhotoAreas = 0;// 当前产品的面积
            WorkOrderFlowList curWfi = null;
            string strIsLoad = "false";

            if (!oi.WorkOrderFlowList.IsLoaded)
            {
                oi.WorkOrderFlowList.Load();
            }
            else
            {
                strIsLoad = "刷新workorderflowlist";
                oi.WorkOrderFlowList.Load(System.Data.Objects.MergeOption.OverwriteChanges);
            }


            foreach (WorkOrderFlowList list in oi.WorkOrderFlowList.ToList())
            {
                if (!list.tb_TechReference.IsLoaded)
                {
                    list.tb_TechReference.Load();
                }
                if (list.tb_Tech.TechType == (int)TechType.FenPian)
                {
                    if (list.tb_Tech.TechId == curTechId && (list.Status == (int)OrderFlowListStatus.Useable || list.Status == (int)OrderFlowListStatus.Wait))
                    {
                        curWfi = list;
                        break;
                    }
                }
                else
                {
                    if (list.tb_Tech.TechId == curTechId && (list.Status == (int)OrderFlowListStatus.Useable || list.Status == (int)OrderFlowListStatus.UseableAccept))
                    {
                        curWfi = list;
                        break;
                    }
                }
            }

            if (curWfi == null)//没有找到当前需要完成的节点
            {
                string curTechName = "";
                WorkOrderFlowList curWFL = oi.WorkOrderFlowList.ToList().FirstOrDefault(w => w.Status == 1 || w.Status == 2);
                if (curWFL == null)
                {
                    curTechName = "此单没有结点处于正在生产！";
                }
                else
                {
                    curTechName = curWFL.tb_Tech.TechName;
                }
                WriteLogForCheck.WriteLogFile(oi.ProductType == 1 ? "返单" : "正常单" + "  定单号：" + oi.OrderProductId.ToString() + "    " + strIsLoad + "   当前节点：" + curTechName + "-----------" + dateTimeNow.ToString());
                return false;
            }
            else//找到了当前的节点
            {
                try
                {
                    #region 完成当前结点
                    foreach (WorkOrderFlowList list in oi.WorkOrderFlowList)
                    {
                        if (!list.tb_TechReference.IsLoaded)
                        {
                            list.tb_TechReference.Load();
                        }
                        if (list.WorkOrder < curWfi.WorkOrder)///找到分片以前的节点并把节点状态标志完成
                        {
                            if (list.Status != (int)OrderFlowListStatus.Complete)
                            {
                                list.Status = (int)OrderFlowListStatus.Complete;
                            }
                        }
                    }

                    curWfi.Status = (int)OrderFlowListStatus.Complete;
                    curWfi.UserId = operUid;
                    curWfi.CompletedTime = dateTimeNow;

                    if (oi.OrderType != (int)OrderInfoType.OutReturnInfo)//只有外部返单的产品时才不需要统计员工的业绩
                    {
                        NewStatWorkerPerformance(curWfi, dataBase);
                    }
                    #endregion

                    WorkOrderFlowList nextWfi = oi.WorkOrderFlowList.ToList().OrderBy(o => o.WorkOrder).FirstOrDefault(o => o.Status == (int)OrderFlowListStatus.Wait);

                    if (nextWfi == null)//是最后一个节点
                    {
                        #region 完成该产品的流程，并做相应的后期处理
                        if (!oi.Tb_OrderBagReference.IsLoaded)
                        {
                            oi.Tb_OrderBagReference.Load();
                        }
                        else
                        {
                            oi.Tb_OrderBagReference.Load(System.Data.Objects.MergeOption.OverwriteChanges);

                        }
                        if (!oi.Tb_OrderBag.orderInfo.IsLoaded)
                        {
                            oi.Tb_OrderBag.orderInfo.Load();
                        }
                        else
                        {
                            dataBase.Refresh(System.Data.Objects.RefreshMode.StoreWins, oi.Tb_OrderBag.orderInfo);
                        }

                        oi.status = (int)OrderInfoStatus.Completed;

                        bool isALLCompleted = true; //此单对应的定单包的包的定单是否都以完成
                        foreach (var item in oi.Tb_OrderBag.orderInfo)
                        {
                            if (item.status != (int)OrderInfoStatus.Completed && item.status != (int)OrderInfoStatus.Deleted)
                            {
                                isALLCompleted = false; //只要有一个不为OVER就退出结束
                                break;
                            }
                        }
                        if (isALLCompleted) //修改tb_orderBag的状态
                        {
                            oi.Tb_OrderBag.Status = (int)OrderBagStatus.Completed;
                            oi.Tb_OrderBag.CompleteTime = dateTimeNow;
                            IsNeedMoveData = true;//当整个ORDERBAG都处于完成状态时，则应将一些信息转移动到备份数据库
                        }
                        oi.CompleteTime = dateTimeNow;
                        #endregion
                    }
                    else//不是最后一个节点
                    {
                        #region 处理流程问题

                        nextWfi.Status = (int)OrderFlowListStatus.Useable;
                        //将此结点以及以后的所有结点的预完成时间推后
                        DateTime curTime = dateTimeNow;
                        foreach (var item in oi.WorkOrderFlowList.Where(o => o.Status == (int)OrderFlowListStatus.Wait || o.Status == (int)OrderFlowListStatus.Useable).OrderBy(o => o.WorkOrder))
                        {
                            item.AssignTime = curTime;
                            if (!item.tb_TechReference.IsLoaded)
                            {
                                item.tb_TechReference.Load();
                            }
                            item.PreCompleteTime = curTime.AddHours(item.tb_Tech.NeedTime);
                            item.CompletedTime = item.PreCompleteTime;
                            curTime = (DateTime)item.PreCompleteTime;

                        }
                        if (!nextWfi.tb_TechReference.IsLoaded)
                        {
                            nextWfi.tb_TechReference.Load();
                        }
                        strNextTechName = nextWfi.tb_Tech.TechName;

                        #endregion

                        if (curWfi.tb_Tech.TechType == (int)TechType.TiaoSe)//如果当前节点为“调色”也就是非实物和实物的交接处
                        {
                            if (!oi.WorkOrderFlowList.IsLoaded)
                            {
                                oi.WorkOrderFlowList.Load();
                            }
                            //if (oi.WorkOrderFlowList.FirstOrDefault(p => p.tb_Tech.IsDesign == true) == null)//设计的不复制
                            //{
                            #region 多张多份的问题

                            //在这里处理多份的问题
                            //1.复制产品,注意需要更新CODE
                            //2.复制照片ID,注意更新CODE
                            //3.复制流程
                            //4.如果有多份产品需要每个产品去进行财务审核
                            //5.产品相关附加收费项目添加
                            if (!oi.Tb_OrderBagReference.IsLoaded)
                            {
                                oi.Tb_OrderBagReference.Load();
                            }
                            if (!oi.Tb_ProductReference.IsLoaded)
                            {
                                oi.Tb_ProductReference.Load();
                            }
                            if (!oi.photoInfo.IsLoaded)
                            {
                                oi.photoInfo.Load();
                            }
                            if (!oi.CommonChargeItem.IsLoaded)
                            {
                                oi.CommonChargeItem.Load();
                            }

                            #region //先处理OI多张照片的问题
                            List<photoInfo> newPhotos = new List<photoInfo>();
                            photoInfo firstPhotoInfo = oi.photoInfo.ToList().FirstOrDefault();//此产品的任意一张图片
                            if (!firstPhotoInfo.paperFaceReference.IsLoaded)
                            {
                                firstPhotoInfo.paperFaceReference.Load();
                            }
                            if (!firstPhotoInfo.paperTypeReference.IsLoaded)
                            {
                                firstPhotoInfo.paperTypeReference.Load();
                            }
                            foreach (var pi in oi.photoInfo.ToList())
                            {
                                for (int i = 0; i < pi.TotalNum - 1; i++)
                                {
                                    if (!pi.orderInfoReference.IsLoaded)
                                    {
                                        pi.orderInfoReference.Load();
                                    }
                                    newPhotos.Add(new photoInfo()
                                    {
                                        OldPicPath = pi.OldPicPath,
                                        Height = pi.Height,
                                        Width = pi.Width,
                                        userId = pi.userId,
                                        status2 = pi.status2,
                                        status = pi.status,
                                        Remark = pi.Remark,
                                        TotalNum = 1,
                                        paperFace = firstPhotoInfo.paperFace,
                                        paperType = firstPhotoInfo.paperType,
                                        MakeUpNum = pi.MakeUpNum,
                                        picPath = pi.picPath,
                                        photoName = pi.photoName + "(" + (i + 1) + "/" + pi.TotalNum + ")",
                                        pixHeight = pi.pixHeight,
                                        pixWidth = pi.pixWidth,
                                        printerId = pi.printerId,
                                        PhotoBarCode = "0",
                                        IsModifySize = pi.IsModifySize,
                                        orderInfo = pi.orderInfo

                                    });
                                }
                                pi.photoName = pi.photoName + "(" + pi.TotalNum + "/" + pi.TotalNum + ")";
                                pi.TotalNum = 1;
                            }

                            foreach (var pi in newPhotos)
                            {
                                oi.photoInfo.Add(pi);
                            }
                            //newPhotos.Clear();

                            #region 可以在此在照片名称后面加上此张片是此产品的中第几张

                            #endregion

                            #endregion

                            if (oi.productNum > 1)
                            {
                                decimal? avgCount = oi.PrePriceCount / oi.productNum;
                                double avgArea = oi.Area / oi.productNum;
                                #region//处理多份的问题
                                for (int i = 0; i < oi.productNum - 1; i++)
                                {
                                    orderInfo oiNew = new orderInfo()
                                    {
                                        CtmName = oi.CtmName,
                                        CompleteTime = oi.CompleteTime,
                                        Height = oi.Height,
                                        Width = oi.Width,
                                        OrderPath = oi.OrderPath,
                                        isCount = oi.isCount,
                                        IsEdit = oi.IsEdit,
                                        OrderProductName = oi.OrderProductName + "(" + (i + 1) + @"/" + oi.productNum + ")",
                                        PageNum = oi.PageNum,
                                        OrilOrderPath = oi.OrilOrderPath,
                                        PrePriceCount = avgCount,//产品的预估金额为总的除以份数
                                        Area = avgArea,//产品的预估面积为总的除以份数
                                        Priority = oi.Priority,
                                        status = oi.status,
                                        productNum = 1,
                                        ProductType = oi.ProductType,
                                        Remark = oi.Remark,
                                        Tb_OrderBag = oi.Tb_OrderBag,
                                        Tb_Product = oi.Tb_Product,
                                        ParentProductId = 0,
                                        OrderProductCode = "0"
                                    };

                                    #region 给新定单添加照片
                                    foreach (var pi in oi.photoInfo)
                                    {
                                        oiNew.photoInfo.Add(new photoInfo()
                                        {
                                            OldPicPath = pi.OldPicPath,
                                            Height = pi.Height,
                                            Width = pi.Width,
                                            userId = pi.userId,
                                            status2 = pi.status2,
                                            status = pi.status,
                                            Remark = pi.Remark,
                                            TotalNum = 1,
                                            paperFace = firstPhotoInfo.paperFace,
                                            paperType = firstPhotoInfo.paperType,
                                            MakeUpNum = pi.MakeUpNum,
                                            picPath = pi.picPath,
                                            photoName = pi.photoName,
                                            pixHeight = pi.pixHeight,
                                            pixWidth = pi.pixWidth,
                                            printerId = pi.printerId,
                                            PhotoBarCode = "0",
                                            IsModifySize = pi.IsModifySize
                                        });
                                    }
                                    #endregion

                                    #region 给新产品添加流程
                                    if (!oi.WorkOrderFlowList.IsLoaded)
                                    {
                                        oi.WorkOrderFlowList.Load();
                                    }

                                    foreach (var wfl in oi.WorkOrderFlowList.ToList())
                                    {
                                        if (!wfl.tb_TechReference.IsLoaded)
                                        {
                                            wfl.tb_TechReference.Load();
                                        }
                                        oiNew.WorkOrderFlowList.Add(new WorkOrderFlowList()
                                        {
                                            AssignTime = wfl.AssignTime,
                                            CompletedTime = wfl.CompletedTime,
                                            IsEdit = wfl.IsEdit,
                                            ReceiveTime = wfl.ReceiveTime,
                                            Status = wfl.Status,
                                            tb_Tech = wfl.tb_Tech,
                                            WorkOrder = wfl.WorkOrder,
                                            UserId = wfl.UserId,
                                            PreCompleteTime = wfl.PreCompleteTime
                                        });
                                    }
                                    #endregion

                                    #region 如果产品指定了委外厂商需要添加相应的委外记录
                                    if (!oi.OutProcessRecord.IsLoaded)
                                    {
                                        oi.OutProcessRecord.Load();
                                    }
                                    if (oi.OutProcessRecord.Count > 0)//有委外记录
                                    {
                                        OutProcessRecord oldOiOut = oi.OutProcessRecord.FirstOrDefault();
                                        if (oldOiOut != null)
                                        {
                                            if (!oldOiOut.OutProcessShopReference.IsLoaded)
                                            {
                                                oldOiOut.OutProcessShopReference.Load();
                                            }
                                            if (!oldOiOut.usersReference.IsLoaded)
                                            {
                                                oldOiOut.usersReference.Load();
                                            }
                                            if (!oldOiOut.users1Reference.IsLoaded)
                                            {
                                                oldOiOut.users1Reference.Load();
                                            }
                                            oiNew.OutProcessRecord.Add(new OutProcessRecord()
                                            {
                                                CreateTime = oldOiOut.CreateTime,
                                                EndProductTime = oldOiOut.EndProductTime,
                                                FetchRemark = oldOiOut.FetchRemark,
                                                FetchTime = oldOiOut.FetchTime,
                                                OperateUser = oldOiOut.OperateUser,
                                                OutProcessShop = oldOiOut.OutProcessShop,
                                                OutRemark = oldOiOut.OutRemark,
                                                PreFetchTime = oldOiOut.PreFetchTime,
                                                Remark = oldOiOut.Remark,
                                                Status = oldOiOut.Status,
                                                Status2 = oldOiOut.Status2,
                                                StartProductTime = oldOiOut.StartProductTime,
                                                users = oldOiOut.users,
                                                users1 = oldOiOut.users1
                                            });

                                        }
                                    }

                                    #endregion
                                    #region//给产品添加相应的附加收费项目
                                    foreach (CommonChargeItem cci in oi.CommonChargeItem)
                                    {
                                        CommonChargeItem ccinew = dataBase.CommonChargeItem.FirstOrDefault(cp => cp.CommonChargeItemId == cci.CommonChargeItemId);
                                        if (!cci.tb_CostTypeReference.IsLoaded)
                                        {
                                            cci.tb_CostTypeReference.Load();
                                        }
                                        if (cci.tb_CostType.TypeName.Contains("设计") || cci.tb_CostType.TypeName.Contains("修片"))//设计修片不复制
                                        {

                                        }

                                        else//其他的收费项目要复制
                                        {
                                            oiNew.CommonChargeItem.Add(ccinew);
                                        }

                                    }
                                    #endregion

                                    oi.Tb_OrderBag.orderInfo.Add(oiNew);

                                }
                                oi.PrePriceCount = avgCount;
                                oi.Area = avgArea;
                                oi.OrderProductName = oi.OrderProductName + "(" + oi.productNum + @"/" + oi.productNum + ")";
                                oi.productNum = 1;

                                if (!oi.Tb_OrderBagReference.IsLoaded)
                                {
                                    oi.Tb_OrderBagReference.Load();
                                }
                                if (!oi.Tb_OrderBag.ShopReference.IsLoaded)
                                {
                                    oi.Tb_OrderBag.ShopReference.Load();
                                }
                                foreach (var oiT in oi.Tb_OrderBag.orderInfo.ToList())
                                {
                                    #region//进行财务审核

                                    if (oi.Tb_OrderBag.Shop.AccountControlTechId == curTechId)
                                    {
                                        BillBLL.CheckOrderCount(oiT, oi.Tb_OrderBag.Shop, false, dataBase);
                                    }
                                    #endregion
                                }

                                #endregion
                            }
                            else//如果只有一份的情况就单独就此份进行财务审核
                            {
                                #region//进行财务审核
                                if (!oi.Tb_OrderBagReference.IsLoaded)
                                {
                                    oi.Tb_OrderBagReference.Load();
                                }
                                if (!oi.Tb_OrderBag.ShopReference.IsLoaded)
                                {
                                    oi.Tb_OrderBag.ShopReference.Load();
                                }
                                if (oi.Tb_OrderBag.Shop.AccountControlTechId == curTechId)
                                {
                                    BillBLL.CheckOrderCount(oi, oi.Tb_OrderBag.Shop, false, dataBase);
                                }
                                #endregion
                            }

                            #endregion
                            //}
                        }

                    }
                    try
                    {

                        dataBase.SaveChanges();
                    }
                    catch (Exception exss)
                    {
                        throw new Exception("检查到商户‘" + oi.Tb_OrderBag.Shop.shopName + "’余额有变动，请重新打印");
                    }

                    #region 更新orderInfo的BARCODE，和PHOTO的BARCODE

                    if (oi.Tb_OrderBag != null)
                    {
                        if (!oi.Tb_OrderBag.orderInfo.IsLoaded)
                        {
                            oi.Tb_OrderBag.orderInfo.Load();
                        }
                        foreach (var oiT in oi.Tb_OrderBag.orderInfo.ToList())
                        {
                            if (oiT.OrderProductCode.Trim() == "0")
                            {
                                oiT.OrderProductCode = "2" + oiT.OrderProductId.ToString().PadLeft(9, '0');
                            }
                            if (!oiT.photoInfo.IsLoaded)
                            {
                                oiT.photoInfo.Load();
                            }
                            List<photoInfo> willDeletePhoto = new List<photoInfo>();
                            foreach (var piT in oiT.photoInfo.ToList())
                            {
                                if (piT.PhotoBarCode.Trim() == "0")
                                {
                                    //if (piT.userId == null)
                                    //{
                                    //    willDeletePhoto.Add(piT);
                                    //}
                                    //else
                                    //{
                                    piT.PhotoBarCode = "3" + piT.photoId.ToString().PadLeft(9, '0');
                                    //}
                                }
                            }
                            //foreach (var pi in willDeletePhoto)
                            //{
                            //    dataBase.DeleteObject(pi);
                            //}
                            //willDeletePhoto.Clear();
                        }

                        dataBase.SaveChanges();
                    }
                    #endregion

                    return true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

        /// <summary>
        /// 统计orderBag的相关数据，包括面积，单数
        /// </summary>
        /// <param name="orderBagId"></param>
        /// <returns>1--代表成功，0--代表失败,失败时已错误写入到日志中</returns>
        public int StataOrderBagInfo(int orderBagId)
        {
            int result = 1;
            using (newSampleYPDBEntities dataBase = new newSampleYPDBEntities())
            {
                Tb_OrderBag tbOrderBag = dataBase.Tb_OrderBag.FirstOrDefault(ob => ob.OrderBagId == orderBagId);
                if (tbOrderBag != null)
                {
                    if (!tbOrderBag.orderInfo.IsLoaded)
                    {
                        tbOrderBag.orderInfo.Load();
                    }

                    foreach (var oi in tbOrderBag.orderInfo.ToList())
                    {
                        //double OiArea = GetAreaByOi(oi, dataBase);
                        SataShopProductAndOrderArea(oi, dataBase, oi.Area);
                        try
                        {
                            dataBase.SaveChanges();
                            //WriteLogForCheck.WriteLogFile("统计完成面积为：" + OiArea.ToString());
                        }
                        catch (Exception ex)//记录日志
                        {
                            //WriteLogForCheck.WriteLogFile("在进行产品和每日开单面积统计时出错：" + ex.Message);
                            result = 0;
                            break;
                        }

                    }
                }
            }
            return result;
        }

        private double GetAreaByOi(orderInfo oi, newSampleYPDBEntities dataBase)
        {
            double photosArea = 0;//面积
            int FactCount = 0;//照片应该被 生产的数量
            photosArea = GetAreaByOi(oi, out FactCount);
            return photosArea;
        }

        /// <summary>
        /// 得到某个产品真实的面积，即打印后是多少面积就是多少面积
        /// </summary>
        /// <param name="oi"></param>
        /// <returns></returns>
        private double GetAreaByOi(orderInfo oi, out int FactCount)
        {
            double photosArea = 0;
            int photoCount = 0;
            FactCount = 0;//照片应该被 生产的数量
            int orderNum = 1;//产品数
            List<photoInfo> photos = new List<photoInfo>();

            if (!oi.photoInfo.IsLoaded)
            {
                oi.photoInfo.Load();
            }
            if (!oi.Tb_ProductReference.IsLoaded)
            {
                oi.Tb_ProductReference.Load();
            }
            if (!oi.Tb_Product.tb_ProductTypeReference.IsLoaded)
            {
                oi.Tb_Product.tb_ProductTypeReference.Load();
            }
            if (!oi.WorkOrderFlowList.IsLoaded)
            {
                oi.WorkOrderFlowList.Load();
            }
            Boolean isDesignProduct = false;
            foreach (WorkOrderFlowList wfl in oi.WorkOrderFlowList)
            {
                wfl.tb_TechReference.Load();
                if (wfl.tb_Tech.IsDesign)
                {
                    isDesignProduct = true;
                    break;
                }
            }

            photos = oi.photoInfo.ToList();
            photoCount = photos.Count;//照片在数据库中的当前数量
            orderNum = oi.productNum;
            FactCount = orderNum * photos.Sum(p => p.TotalNum == null ? 1 : (int)p.TotalNum);

            //if (Convert.ToInt32(oi.Tb_Product.tb_ProductType.ProductTypeCode) == 6)//如果是扩印类产品就以产品的尺寸做为面积的计算标准
            //{
            //    photosArea = oi.Tb_Product.Width * oi.Tb_Product.Height * (double)FactCount;
            //}
            int productCode = Convert.ToInt32(oi.Tb_Product.tb_ProductType.ProductTypeCode);
            //if (productCode == (int)(OrderInfoProductType.NeedDesignProduct) || productCode == (int)(OrderInfoProductType.NeedDesignPrint) || productCode == (int)(OrderInfoProductType.NeedDesignKuoYin))//需要设计的产品直出类按照产品的尺寸和指定的页数估算面积
            //{
            //    photosArea = oi.Tb_Product.Width * oi.Tb_Product.Height * oi.productNum*oi.PageNum;
            //}
            //else if (productCode == (int)(OrderInfoProductType.NoNeedDesignKuoYin))//不需要设计的产品面积按产品尺寸估算，照片数按实际算
            //{
            //    photosArea = oi.Tb_Product.Width * oi.Tb_Product.Height * FactCount;
            //}
            //else if (productCode == (int)(OrderInfoProductType.NoNeedDesignPrint)||productCode == (int)(OrderInfoProductType.NoNeedDesignProduct))//不需要设计的直出算实际的面积
            //{
            //    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * oi.productNum);
            //}
            //else
            //{
            //    //if (FactCount > photoCount)
            //    //{
            //    //    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * oi.productNum);
            //    //}
            //    //else if (FactCount == photoCount)
            //    //{
            //    //    photosArea = photos.Sum(p => p.Width * p.Height);
            //    //}
            //    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * oi.productNum);
            //}
            if (isDesignProduct)//需要设计的产品
            {
                photosArea = oi.Tb_Product.Width * oi.Tb_Product.Height * oi.productNum * oi.PageNum;
            }
            else//不需要设计的产品和扩印
            {
                if (productCode == (int)(OrderInfoProductType.NoNeedDesignKuoYin))//不需要设计的产品面积按产品尺寸估算，照片数按实际算
                {
                    photosArea = oi.Tb_Product.Width * oi.Tb_Product.Height * FactCount;
                }
                else if (productCode == (int)(OrderInfoProductType.NoNeedDesignPrint) || productCode == (int)(OrderInfoProductType.NoNeedDesignProduct))//不需要设计的直出算实际的面积
                {
                    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * oi.productNum);
                }
                else
                {
                    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * oi.productNum);

                }
            }
            photosArea = photosArea * 2.54 * 2.54 / 10000;//平方米

            return photosArea;
        }

        #region help methods


        private void SataShopProductAndOrderArea(orderInfo oi, newSampleYPDBEntities dataBase, double PhotoAreas)//统计商户的开单产品和开单面积
        {
            if (!oi.Tb_ProductReference.IsLoaded)
                oi.Tb_ProductReference.Load();

            if (!oi.Tb_OrderBagReference.IsLoaded)
                oi.Tb_OrderBagReference.Load();

            if (!oi.Tb_OrderBag.ShopReference.IsLoaded)
                oi.Tb_OrderBag.ShopReference.Load();

            #region 商户下单产品统计

            string strSpc = oi.Tb_Product.Width + "*" + oi.Tb_Product.Height;
            ShopProduct sp = dataBase.ShopProduct.FirstOrDefault(p => p.ShopName == oi.Tb_OrderBag.Shop.shopName && p.ProductName == oi.Tb_Product.ProductName && p.Spec == strSpc && p.OrderTime == oi.Tb_OrderBag.OrderTime.Date);

            if (sp == null)//添加新的
            {
                ShopProduct spNew = new ShopProduct()
                {
                    Area = PhotoAreas,
                    OrderTime = oi.Tb_OrderBag.OrderTime.Date,
                    ProductName = oi.Tb_Product.ProductName,
                    ProductNum = 1,
                    ShopName = oi.Tb_OrderBag.Shop.shopName,
                    Spec = oi.Tb_Product.Width + "*" + oi.Tb_Product.Height
                };
                dataBase.AddToShopProduct(spNew);
            }
            else
            {
                sp.Area += PhotoAreas;
                sp.ProductNum++;
            }

            #endregion

            #region 每日开单面积统计

            CreateOrderAreaByDay orderArea = dataBase.CreateOrderAreaByDay.FirstOrDefault(d => d.CreateOrderDate == oi.Tb_OrderBag.OrderTime.Date && d.AreaName == oi.Tb_OrderBag.Shop.Area && d.ShopName == oi.Tb_OrderBag.Shop.shopName);
            if (orderArea == null)
            {
                CreateOrderAreaByDay newDay = new CreateOrderAreaByDay()
                {
                    CreateOrderDate = oi.Tb_OrderBag.OrderTime.Date,
                    Area = PhotoAreas,
                    ShopName = oi.Tb_OrderBag.Shop.shopName,
                    AreaName = oi.Tb_OrderBag.Shop.Area
                };
                dataBase.AddToCreateOrderAreaByDay(newDay);
            }
            else
            {
                orderArea.Area += PhotoAreas;
            }
            #endregion

        }
        /// <summary>
        /// 修改删除时用
        /// </summary>
        /// <param name="oi"></param>
        /// <param name="dataBase"></param>
        /// <param name="inOldAreas,inNewOldAreas">-1,N -新增；n,-1 -删除；n,n-修改</param>
        public void SataShopProductAndOrderAreaForUpdata(int inOrderProductid, double inOldAreas, double inNewOldAreas, newSampleYPDBEntities dataBase)//统计商户的开单产品和开单面积
        {

            orderInfo oi = dataBase.orderInfo.FirstOrDefault(p => p.OrderProductId == inOrderProductid);
            if (!oi.Tb_ProductReference.IsLoaded)
                oi.Tb_ProductReference.Load();

            if (!oi.Tb_OrderBagReference.IsLoaded)
                oi.Tb_OrderBagReference.Load();

            if (!oi.Tb_OrderBag.ShopReference.IsLoaded)
                oi.Tb_OrderBag.ShopReference.Load();

            #region 商户下单产品统计

            string strSpc = oi.Tb_Product.Width + "*" + oi.Tb_Product.Height;
            ShopProduct sp = dataBase.ShopProduct.FirstOrDefault(p => p.ShopName == oi.Tb_OrderBag.Shop.shopName && p.ProductName == oi.Tb_Product.ProductName && p.Spec == strSpc && p.OrderTime == oi.Tb_OrderBag.OrderTime.Date);
            if (inOldAreas == -1 && inNewOldAreas != -1)
            {
                if (sp == null)//添加新的
                {
                    ShopProduct spNew = new ShopProduct()
                    {
                        Area = inNewOldAreas,
                        OrderTime = oi.Tb_OrderBag.OrderTime.Date,
                        ProductName = oi.Tb_Product.ProductName,
                        ProductNum = 1,
                        ShopName = oi.Tb_OrderBag.Shop.shopName,
                        Spec = oi.Tb_Product.Width + "*" + oi.Tb_Product.Height
                    };
                    dataBase.AddToShopProduct(spNew);
                }
                else
                {
                    sp.Area += inNewOldAreas;
                    sp.ProductNum++;
                }
            }
            else if (inOldAreas != -1 && inNewOldAreas == -1)
            {
                if (sp == null)//没有记录，错误的商户才会有这种
                {

                }
                else
                {
                    sp.Area -= inOldAreas;
                    sp.ProductNum--;
                }
            }
            else if (inOldAreas != -1 && inNewOldAreas != -1)
            {
                if (sp == null)//没有记录，错误的商户才会有这种
                {
                    ShopProduct spNew = new ShopProduct()
                    {
                        Area = inNewOldAreas,
                        OrderTime = oi.Tb_OrderBag.OrderTime.Date,
                        ProductName = oi.Tb_Product.ProductName,
                        ProductNum = 1,
                        ShopName = oi.Tb_OrderBag.Shop.shopName,
                        Spec = oi.Tb_Product.Width + "*" + oi.Tb_Product.Height
                    };
                    dataBase.AddToShopProduct(spNew);
                }
                else
                {
                    sp.Area -= inOldAreas;
                    sp.Area += inNewOldAreas;

                }
            }

            #endregion

            #region 每日开单面积统计

            CreateOrderAreaByDay orderArea = dataBase.CreateOrderAreaByDay.FirstOrDefault(d => d.CreateOrderDate == oi.Tb_OrderBag.OrderTime.Date && d.AreaName == oi.Tb_OrderBag.Shop.Area && d.ShopName == oi.Tb_OrderBag.Shop.shopName);

            if (inOldAreas == -1 && inNewOldAreas != -1)
            {
                if (orderArea == null)
                {
                    CreateOrderAreaByDay newDay = new CreateOrderAreaByDay()
                    {
                        CreateOrderDate = oi.Tb_OrderBag.OrderTime.Date,
                        Area = inNewOldAreas,
                        ShopName = oi.Tb_OrderBag.Shop.shopName,
                        AreaName = oi.Tb_OrderBag.Shop.Area
                    };
                    dataBase.AddToCreateOrderAreaByDay(newDay);
                }
                else
                {
                    orderArea.Area += inNewOldAreas;
                }
            }
            else if (inOldAreas != -1 && inNewOldAreas == -1)
            {
                if (orderArea == null)
                {

                }
                else
                {
                    orderArea.Area -= inOldAreas;
                }
            }
            else if (inOldAreas != -1 && inNewOldAreas != -1)
            {
                if (orderArea == null)
                {
                    CreateOrderAreaByDay newDay = new CreateOrderAreaByDay()
                    {
                        CreateOrderDate = oi.Tb_OrderBag.OrderTime.Date,
                        Area = inNewOldAreas,
                        ShopName = oi.Tb_OrderBag.Shop.shopName,
                        AreaName = oi.Tb_OrderBag.Shop.Area
                    };
                    dataBase.AddToCreateOrderAreaByDay(newDay);
                }
                else
                {
                    orderArea.Area -= inOldAreas;
                    orderArea.Area += inNewOldAreas;
                }
            }
            dataBase.SaveChanges();
            #endregion


        }

        /// <summary>
        /// 及于统计员工业绩，已作废
        /// </summary>
        /// <param name="wfi"></param>
        /// <param name="dataBase"></param>
        /// <param name="photosArea"></param>
        public void StatWorkerPerfmance(WorkOrderFlowList wfi, newSampleYPDBEntities dataBase, out double photosArea)//统计完员工业绩
        {
            photosArea = 0;
            int FactCount = 0;

            users curWorker = dataBase.users.FirstOrDefault(u => u.userID == wfi.UserId);
            if (!curWorker.tb_WorkerGroupReference.IsLoaded)
            {
                curWorker.tb_WorkerGroupReference.Load();
            }
            if (!wfi.orderInfoReference.IsLoaded)
            {
                wfi.orderInfoReference.Load();
            }

            photosArea = GetAreaByOi(wfi.orderInfo, out FactCount);

            //int photoCount = 0;
            //int FactCount = 0;//照片应该被 生产的数量
            //int orderNum = 1;//产品数

            //if (!wfi.orderInfo.photoInfo.IsLoaded)
            //{
            //    wfi.orderInfo.photoInfo.Load();
            //}
            //List<photoInfo> photos = wfi.orderInfo.photoInfo.ToList();
            //photoCount = photos.Count;//照片在数据库中的当前数量
            //orderNum = wfi.orderInfo.productNum;
            //FactCount = orderNum * (int)photos.Sum(p => p.TotalNum);

            //if (FactCount > photoCount)
            //{
            //    photosArea = photos.Sum(p => p.Width * p.Height * (int)p.TotalNum * wfi.orderInfo.productNum);

            //}
            //else if (FactCount == photoCount)
            //{
            //    photosArea = photos.Sum(p => p.Width * p.Height);
            //}

            //photosArea = photosArea * 2.54 * 2.54 / 10000;//平方米


            EmployeePerformance ep = dataBase.EmployeePerformance.FirstOrDefault(e => e.Tech == wfi.tb_Tech.TechName && e.UserName == curWorker.UserName && e.CompleteDate == ((DateTime)wfi.CompletedTime).Date);
            if (ep == null)//添加一新记录
            {
                EmployeePerformance newEp = new EmployeePerformance() { Areas = photosArea, CompleteDate = ((DateTime)wfi.CompletedTime).Date, Departments = curWorker.tb_WorkerGroup.GroupName, OrderNum = wfi.orderInfo.productNum, PhotoNum = FactCount, Tech = wfi.tb_Tech.TechName, UserName = curWorker.UserName };
                dataBase.AddToEmployeePerformance(newEp);
            }
            else
            {
                ep.OrderNum += wfi.orderInfo.productNum;
                ep.PhotoNum += FactCount;
                ep.Areas += photosArea;
            }

        }


        /// <summary>
        /// 新的统计员工业绩
        /// </summary>
        /// <param name="wfi"></param>
        /// <param name="dataBase"></param>
        public void NewStatWorkerPerformance(WorkOrderFlowList wfi, newSampleYPDBEntities dataBase)
        {
            users curWorker = dataBase.users.FirstOrDefault(u => u.userID == wfi.UserId);
            if (!curWorker.tb_WorkerGroupReference.IsLoaded)
            {
                curWorker.tb_WorkerGroupReference.Load();
            }
            if (!wfi.orderInfoReference.IsLoaded)
            {
                wfi.orderInfoReference.Load();
            }
            if (!wfi.orderInfo.Tb_OrderBagReference.IsLoaded)
            {
                wfi.orderInfo.Tb_OrderBagReference.Load();
            }
            if (!wfi.tb_TechReference.IsLoaded)
            {
                wfi.tb_TechReference.Load();
            }
            if (!wfi.orderInfo.Tb_OrderBag.ShopReference.IsLoaded)
            {
                wfi.orderInfo.Tb_OrderBag.ShopReference.Load();
            }
            if (!wfi.orderInfo.photoInfo.IsLoaded)
            {
                wfi.orderInfo.photoInfo.Load();
            }
            //if (!wfi.orderInfo.Tb_OrderBagReference.IsLoaded)
            //{
            //    wfi.orderInfo.Tb_OrderBagReference.Load();
            //}
            //if (!wfi.orderInfo.Tb_OrderBag.ShopReference.IsLoaded)
            //{
            //    wfi.orderInfo.Tb_OrderBag.ShopReference.Load();
            //}

            //查看该产品的该节点是否存在，如果存在，则更新，如果不存在则添加
            New_EmployeePerformance curEmp = dataBase.New_EmployeePerformance.FirstOrDefault(em => em.OrderproductId == wfi.orderInfo.OrderProductId && em.TechId == wfi.tb_Tech.TechId);
            if (curEmp != null)//更新
            {
                curEmp.TechCompletedTime = wfi.CompletedTime ?? DateTime.Now;
                curEmp.UserId = wfi.UserId;
                curEmp.SinglePageNum = wfi.orderInfo.SinglePageNum;
                curEmp.PhotoTotalNum = wfi.orderInfo.photoInfo.Count;
                curEmp.MultiplePageNum = wfi.orderInfo.MultiPageNum;
                //curEmp.OrderArea = wfi.orderInfo.Area;
                double areas = 0;
                if (!wfi.orderInfoReference.IsLoaded)
                {
                    wfi.orderInfoReference.Load();
                }
                if (!wfi.orderInfo.Tb_ProductReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_ProductReference.Load();
                }
                if (!wfi.orderInfo.Tb_Product.tb_ProductTypeReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_Product.tb_ProductTypeReference.Load();
                }
                if (wfi.orderInfo.Tb_Product.tb_ProductType.ProductTypeCode == 5 || wfi.orderInfo.Tb_Product.tb_ProductType.ProductTypeCode == 6)
                {
                    areas = wfi.orderInfo.productNum * (wfi.orderInfo.photoInfo.Sum(ph => (double)ph.TotalNum) * wfi.orderInfo.Tb_Product.Width * wfi.orderInfo.Tb_Product.Height * 2.54 * 2.54 / 10000);
                }
                else
                {
                    areas = wfi.orderInfo.productNum * wfi.orderInfo.photoInfo.Sum(p => (double)p.TotalNum * p.Width * p.Height * 2.54 * 2.54 / 10000);
                }
                //foreach (photoInfo photo in wfi.orderInfo.photoInfo)
                //{
                //    areas += photo.Width * photo.Height * 2.54 * 2.54 / 10000;
                //}
                curEmp.OrderArea = areas;
                curEmp.PreOrderAreas = areas;
                //curEmp.OrderArea = wfi.orderInfo.photoInfo.Count(p=>p.Width*p.Height*2.54*2.54/10000);
                curEmp.ReceivedTime = wfi.AssignTime ?? DateTime.Now;
                curEmp.ProductPhotoNum = 0;

            }
            else//添加
            {
                double areas = 0;
                if (!wfi.orderInfoReference.IsLoaded)
                {
                    wfi.orderInfoReference.Load();
                }
                if (!wfi.orderInfo.Tb_ProductReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_ProductReference.Load();
                }
                if (!wfi.orderInfo.Tb_Product.tb_ProductTypeReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_Product.tb_ProductTypeReference.Load();
                }
                if (wfi.orderInfo.Tb_Product.tb_ProductType.ProductTypeCode == 5 || wfi.orderInfo.Tb_Product.tb_ProductType.ProductTypeCode == 6)
                {
                    areas = wfi.orderInfo.productNum * (wfi.orderInfo.photoInfo.Sum(ph => (double)ph.TotalNum) * wfi.orderInfo.Tb_Product.Width * wfi.orderInfo.Tb_Product.Height * 2.54 * 2.54 / 10000);
                }
                else
                {
                    areas = wfi.orderInfo.productNum * wfi.orderInfo.photoInfo.Sum(p => (double)p.TotalNum * p.Width * p.Height * 2.54 * 2.54 / 10000);
                }
                //foreach (photoInfo photo in wfi.orderInfo.photoInfo)
                //{
                //    areas += photo.Width * photo.Height * 2.54 * 2.54 / 10000;
                //}
                New_EmployeePerformance curEmpToAdd = new New_EmployeePerformance()
                {
                    CtmName = wfi.orderInfo.CtmName,
                    MultiplePageNum = wfi.orderInfo.MultiPageNum,

                    OrderArea = areas,//结单时的面积（这里只是预设）
                    PreOrderAreas = areas,//开单时的面积
                    OrderConpletedTime = wfi.orderInfo.CompleteTime,
                    OrderCount = 0,
                    OrderPath = wfi.orderInfo.OrderPath,
                    OrderCreateTime = wfi.orderInfo.Tb_OrderBag.OrderTime,
                    OrderproductId = wfi.orderInfo.OrderProductId,
                    OrderProductName = wfi.orderInfo.OrderProductName,
                    PhotoTotalNum = wfi.orderInfo.photoInfo.Count,
                    Status = wfi.orderInfo.status,
                    ShopName = wfi.orderInfo.Tb_OrderBag.Shop.shopName,
                    ReceivedTime = wfi.ReceiveTime ?? DateTime.Now,
                    SinglePageNum = wfi.orderInfo.SinglePageNum,
                    TechCompletedTime = wfi.CompletedTime ?? DateTime.Now,
                    TechId = wfi.tb_Tech.TechId,
                    UserId = wfi.UserId,
                    ProductPhotoNum = wfi.orderInfo.photoInfo.Count == 0 ? 0 : Convert.ToInt32(wfi.orderInfo.productNum * (wfi.orderInfo.photoInfo.Sum(ph => ph.TotalNum)))

                };
                dataBase.AddToNew_EmployeePerformance(curEmpToAdd);
            }

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="inOrderProductid"></param>
        /// <param name="inWorkOrderFlowListID">-1表示更新该产品所有的节点业绩，n表示该产品的n流程的业绩</param>
        /// <param name="inNew"></param>
        public void NewStatWorkerPerformance(int inOrderProductid, int inWorkOrderFlowListID, New_EmployeePerformance inNew, newSampleYPDBEntities dataBase)
        {

            if (inWorkOrderFlowListID != -1)
            {
                WorkOrderFlowList wfi = dataBase.WorkOrderFlowList.FirstOrDefault(p => p.WorkFlowListId == inWorkOrderFlowListID);
                users curWorker = dataBase.users.FirstOrDefault(u => u.userID == wfi.UserId);
                if (!curWorker.tb_WorkerGroupReference.IsLoaded)
                {
                    curWorker.tb_WorkerGroupReference.Load();
                }
                if (!wfi.orderInfoReference.IsLoaded)
                {
                    wfi.orderInfoReference.Load();
                }
                if (!wfi.orderInfo.Tb_OrderBagReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_OrderBagReference.Load();
                }
                if (!wfi.tb_TechReference.IsLoaded)
                {
                    wfi.tb_TechReference.Load();
                }
                if (!wfi.orderInfo.Tb_OrderBag.ShopReference.IsLoaded)
                {
                    wfi.orderInfo.Tb_OrderBag.ShopReference.Load();
                }
                if (!wfi.orderInfo.photoInfo.IsLoaded)
                {
                    wfi.orderInfo.photoInfo.Load();
                }

                //查看该产品的该节点是否存在，如果存在，则更新，如果不存在则添加
                New_EmployeePerformance curEmp = dataBase.New_EmployeePerformance.FirstOrDefault(em => em.OrderproductId == wfi.orderInfo.OrderProductId && em.TechId == wfi.tb_Tech.TechId);
                if (curEmp != null)//更新
                {
                    curEmp.TechCompletedTime = wfi.CompletedTime ?? DateTime.Now;
                    curEmp.UserId = wfi.UserId;
                    curEmp.SinglePageNum = wfi.orderInfo.SinglePageNum;
                    curEmp.PhotoTotalNum = wfi.orderInfo.PageNum;
                    curEmp.MultiplePageNum = wfi.orderInfo.MultiPageNum;
                    curEmp.OrderArea = wfi.orderInfo.Area;
                    curEmp.ReceivedTime = wfi.AssignTime ?? DateTime.Now;
                    curEmp.ProductPhotoNum = wfi.orderInfo.photoInfo.Count == 0 ? 0 : Convert.ToInt32(wfi.orderInfo.productNum * (wfi.orderInfo.photoInfo.Sum(ph => ph.TotalNum)));

                }
                else//添加
                {
                    New_EmployeePerformance curEmpToAdd = new New_EmployeePerformance()
                    {
                        CtmName = wfi.orderInfo.CtmName,
                        MultiplePageNum = wfi.orderInfo.MultiPageNum,
                        OrderArea = wfi.orderInfo.Area,//结单时的面积（这里只是预设）
                        PreOrderAreas = wfi.orderInfo.Area,//开单时的面积
                        OrderConpletedTime = wfi.orderInfo.CompleteTime,
                        OrderCount = wfi.orderInfo.PrePriceCount ?? 0,
                        OrderPath = wfi.orderInfo.OrderPath,
                        OrderCreateTime = wfi.orderInfo.Tb_OrderBag.OrderTime,
                        OrderproductId = wfi.orderInfo.OrderProductId,
                        OrderProductName = wfi.orderInfo.OrderProductName,
                        PhotoTotalNum = wfi.orderInfo.PageNum,
                        Status = wfi.orderInfo.status,
                        ShopName = wfi.orderInfo.Tb_OrderBag.Shop.shopName,
                        ReceivedTime = wfi.ReceiveTime ?? DateTime.Now,
                        SinglePageNum = wfi.orderInfo.SinglePageNum,
                        TechCompletedTime = wfi.CompletedTime ?? DateTime.Now,
                        TechId = wfi.tb_Tech.TechId,
                        UserId = wfi.UserId,
                        ProductPhotoNum = wfi.orderInfo.photoInfo.Count == 0 ? 0 : Convert.ToInt32(wfi.orderInfo.productNum * (wfi.orderInfo.photoInfo.Sum(ph => ph.TotalNum)))

                    };
                    dataBase.AddToNew_EmployeePerformance(curEmpToAdd);
                }
            }
            else
            {
                orderInfo oi = dataBase.orderInfo.FirstOrDefault(p => p.OrderProductId == inOrderProductid);

                if (oi != null)
                {
                    oi.photoInfo.Load();
                    int allPhotoCount = Convert.ToInt32(oi.productNum * (oi.photoInfo.Sum(ph => ph.TotalNum)));
                    List<New_EmployeePerformance> listNep = dataBase.New_EmployeePerformance.Where(p => p.OrderproductId == inOrderProductid).ToList();
                    foreach (New_EmployeePerformance nep in listNep)
                    {

                        nep.SinglePageNum = inNew.SinglePageNum;
                        nep.MultiplePageNum = inNew.MultiplePageNum;
                        nep.OrderArea = inNew.OrderArea;
                        nep.PreOrderAreas = inNew.OrderArea;
                        nep.PhotoTotalNum = inNew.PhotoTotalNum;
                        nep.ProductPhotoNum = allPhotoCount;
                    }
                }
            }
            dataBase.SaveChanges();


        }
        private bool IsAllComplete(int inProductID, newSampleYPDBEntities dataBase)
        {

            //int status = (int)OrderInfoStatus.Doing;
            List<orderInfo> childOrderList = dataBase.orderInfo.Where(p => p.ParentProductId == inProductID).ToList();
            foreach (var oi in childOrderList)
            {
                if (oi.status != 8)
                {
                    return false;
                }
            }
            //int count = childOrderList.Count();
            //if (count > 0)
            //    return false;
            //else
            return true;
        }
        #endregion



        public bool OverCurTech(int curTechId, int operUid, orderInfo oi, newSampleYPDBEntities dataBase, out string strNextTechName)
        {
            bool IsNeedMoveData = false;
            return OverCurTechBase(curTechId, operUid, oi, dataBase, out strNextTechName, out IsNeedMoveData);
        }


        public bool OverCurTech(int curTechId, int operUid, int orderProductId)
        {
            bool result = false;
            string strNextTName = "";
            //object obj = null;

            using (newSampleYPDBEntities dataBase = new newSampleYPDBEntities())
            {
                //dataBase.TryGetObjectByKey(new EntityKey("NewSampleYPDBEntities.orderInfo", "OrderProductId", orderProductId), out obj);
                //orderInfo oi = (orderInfo)obj;
                orderInfo oi = dataBase.orderInfo.FirstOrDefault(o => o.OrderProductId == orderProductId);
                bool IsNeedMoveData = false;
                result = OverCurTechBase(curTechId, operUid, oi, dataBase, out strNextTName, out IsNeedMoveData);
            }

            return result;
        }

        public bool OverCurTech(int curTechId, int operUid, orderInfo oi, newSampleYPDBEntities dataBase)
        {
            string strNextTName = "";
            bool IsNeedMoveData = false;
            return OverCurTechBase(curTechId, operUid, oi, dataBase, out strNextTName, out IsNeedMoveData);
        }

        /// <summary>
        /// 分堆传用
        /// </summary>
        /// <param name="curTechId"></param>
        /// <param name="operUid"></param>
        /// <param name="oi"></param>
        /// <param name="dataBase"></param>
        /// <param name="IsNeedMoveData"></param>
        /// <returns></returns>
        public bool OverCurTech(int curTechId, int operUid, orderInfo oi, newSampleYPDBEntities dataBase, out bool IsNeedMoveData)
        {
            string strNextName = "";
            IsNeedMoveData = false;
            return OverCurTechBase(curTechId, operUid, oi, dataBase, out strNextName, out IsNeedMoveData);
        }


    }
}
